package org.oos.atom.elements;

import static org.oos.model.UserAvatar.DEFAULT_AVATAR;

import java.io.Serializable;

import org.oos.model.UserAvatar;

import com.google.api.client.util.Key;

public class SavedByUser implements Serializable, Cloneable, Author {
	
	private static final long serialVersionUID = 1L;

	@Key("nick")
	private String nick;

	@Key("oos:avatar")
	private String avatarUrl;
	private UserAvatar avatar;
	
	@Key("oos:slug")
	private String slug;

	@Override
	public String getNick() {
		return nick;
	}

	@Override
	public String getSlug() {
		return slug;
	}

	@Override
	public UserAvatar getAvatar() {
		if (avatarUrl != null) {
			if (avatar == null) {
				avatar = new UserAvatar(avatarUrl);
			}
			return avatar;
		} else {
			return DEFAULT_AVATAR;
		}
	}
}
